<template>
  <view class="work-page">
    <!-- 所有组件模板都必须包含的部分 -->
    <WorkHead :workMainData="workMainData"></WorkHead>
    <WorkRequire :workMainData="workMainData" :temp="temp"></WorkRequire>
    <WorkSub0 v-if="temp === 0"></WorkSub0>
    <WorkSub4 v-if="temp === 4"></WorkSub4>
    <WorkSub5 v-if="temp === 5"></WorkSub5>
    <WorkSub6 v-if="temp === 6"></WorkSub6>
    <WorkSub2 v-if="temp === 2 || temp === 10"></WorkSub2>
    <WorkSub3 v-if="temp === 3"></WorkSub3>
    <!-- 签名 所有组件模板都必须包含的部分-->
    <WorkSignature></WorkSignature>
  </view>
</template>

<script setup>
// const { safeAreaInsets } = uni.getSystemInfoSync()
import { onShow, onReady } from '@dcloudio/uni-app'
import { ref, onMounted } from 'vue'
import { useWorkmainStore, useWorksubStore, useUserStore } from '@/stores'
const workMain = useWorkmainStore()
const worksubStore = useWorksubStore()
const useStore = useUserStore()
// const worksubData = ref()
//当前用户
const currentUser = ref()

// // 路由参数work-main_id
const workMainId = ref()
// // 当前work-main数据
const workMainData = ref({})

const temp = ref(-1)

onShow(() => {
  //   //当前登录的用户信息
  currentUser.value = [useStore.userInfo.uid, useStore.userInfo.name]
  workMainId.value = worksubStore.currentWorkMainId
  //货期worksubData
  // worksubData.value = worksubStore.records[workMainId.value]
  const workMainIndex = workMain.records.findIndex((item) => item.id == workMainId.value)
  workMainData.value = workMain.records[workMainIndex]
  temp.value = Number(workMainData.value.temp)
  //   // uni.pageScrollTo({
  //   //   selector: '.header',
  //   // })
})
onMounted(() => {
  //   //当前登录的用户信息
  currentUser.value = [useStore.userInfo.uid, useStore.userInfo.name]
  workMainId.value = worksubStore.currentWorkMainId
  //货期worksubData
  // worksubData.value = worksubStore.records[workMainId.value]
  const workMainIndex = workMain.records.findIndex((item) => item.id == workMainId.value)
  workMainData.value = workMain.records[workMainIndex]
  temp.value = Number(workMainData.value.temp)
})
</script>

<style lang="scss" scoped>
.work-page {
  .margin-top-bottom {
    margin: 10px 0;
  }
  .grp {
    margin: 20px 0;
  }
}
</style>
